/*
 * Copyright (C) 2018 Logos Technology Ltd.
 */

package com.logos.tool;

/**
 * @author Young Ken
 */

public class DensityUtil {

    /**
     * dip to px
     *
     * @param dpValue value
     * @return px
     */
    public static int dip2px(float dpValue) {
        float scale = ApplicationUtil.getContext().getResources().getDisplayMetrics().density;
        return (int) (dpValue * scale + 0.5f);
    }

    /**
     * px to dip
     *
     * @param pxValue value
     * @return dip
     */
    public static int px2dip(float pxValue) {
        float scale = ApplicationUtil.getContext().getResources().getDisplayMetrics().density;
        return (int) (pxValue / scale + 0.5f);
    }
}
